package com.cx.mapper;

import com.cx.dto.ProjectDTO;
import com.cx.dto.ProjectPageDTO;
import com.cx.pojo.Project;
import com.cx.vo.CommonVO;
import com.cx.vo.StatusAndCountOfTaskVO;
import com.cx.vo.TaskOfProjectVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface ProjectMapper {
    int add(ProjectDTO projectDTO);

    Page<Project> pageQuery(ProjectPageDTO projectPageDTO);

    @Select("select * from project where id = #{id}")
    Project selectById(Integer id);

    @Update("update project set status = #{status} where id = #{id}")
    void updateStatusById(@Param("id") Integer id, @Param("status") Integer status);

    int updateProjectById(ProjectDTO projectDTO);

    @Delete("delete from project where id = #{id}")
    int deleteProById(Integer id);

    @Select("select * from project where status < #{status} and  end_time < #{time}")
    List<Project> getByStatusAndTimeProjectTimeLT(@Param("status") Integer status, @Param("time") LocalDateTime time);


    void update(Project project);

    @Select("select id,name projectName from project")
    List<TaskOfProjectVO> selectTaskOfProject();

    List<StatusAndCountOfTaskVO> selectStatusAndCountOfTaskVO();

    @Select("select u.username name, p.name pOt from project p,user u where p.user_id = u.id and u.status = 2;")
    List<CommonVO> selectUserOfProject();

    @Select("select * from project where user_id = #{id}")
    List<Project> selectProjectByUserId(Long id);
}
